/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package regras;

import Interfaces.CheckerRule;

/**
 *
 * @author Tainá, Ana Luiza e Amanda
 */
public class RuleLetterSequence02 implements CheckerRule{
    private String password;
    public RuleLetterSequence02(String password) {
        this.password = password;
    }
    
    @Override
    public int rule(){
        String alphas = "abcdefghijlmnopqrstuvwxyz";
        int total = 0;
        int sequenceAlpha = 0;
        for (int s=0; s < 22; s++) { 
             String aFwd = alphas.substring(s,s+3); 
             String aRev = new StringBuffer(aFwd).reverse().toString(); 
             if (password.toLowerCase().indexOf(aFwd) != -1 || password.toLowerCase().indexOf(aRev) != -1)
                  sequenceAlpha++;
        }
        if (sequenceAlpha >0)
            total -= sequenceAlpha * 3;
        
        return total; 
   }
}
